package com.adams.custom.page.util;

import org.aspectj.lang.ProceedingJoinPoint;

/**
 * 
 * File Name : DataOperateMessageInterceptor.java
 * 
 * @Description : 数据操作信息拦截器
 */
public class DataOperateMessageAdvice
{

	public Object invoke(ProceedingJoinPoint pjp) throws Throwable
	{
		String className = pjp.getTarget().getClass().getName();
		String methodName = pjp.getSignature().getName();
		String key = className + "." + methodName + "()";
		DataOperateMessageUtil.pushMethodName(key);
		Object result = null;
		try
		{
			result = pjp.proceed();
		} catch (Throwable e)
		{
			if (DataOperateMessageUtil.isEmptyMethodStack())
			{
				DataOperateMessageUtil.clearDataOperateMessages();
			}
			throw e;
		}
		if (DataOperateMessageUtil.isEmptyMethodStack())
		{
			DataOperateMessageUtil.sendDataOperateMessages();
		}
		return result;
	}
}
